#!/usr/bin/env python
# -*- conding: utf-8 -*-

import sys
import Options

APPNAME = 'stupa-evhttp'
VERSION = '0.0.3'

srcdir = '.'
blddir = 'build'

def set_options(opt):
    opt.tool_options('compiler_cxx')
    opt.tool_options('unittestt')

def configure(conf):
    conf.env.CPPPATH = ['/usr/local/include', '/usr/local/include/stupa']
    conf.env.CXXFLAGS += ['-O2', '-Wall']
    conf.env.LIBPATH  += ['/usr/local/lib']

    conf.check_tool('compiler_cxx')
    conf.check_tool('unittestt')

    # check libraries
    conf.check_cxx(lib = 'pthread', mandatory = True)
    conf.check_cxx(lib = 'event', mandatory = True)
    conf.check_cxx(lib = 'stupa', mandatory = True)
    conf.check_cxx(header_name = 'evhttp.h', mandatory = True)
    conf.check_cxx(header_name = 'event.h', mandatory = True)
    conf.check_cxx(header_name = 'stupa.h', mandatory = True)

    #conf.write_config_header('config.h')

def build(bld):
    task1 = bld(
        features = 'cxx cprogram',
        source   = 'stupa_evhttpd.cc handler.cc thread.cc',
        name     = 'stupa_evhttpd',
        target   = 'stupa_evhttpd',
        includes = '. /usr/local/include/stupa',
        lib      = ['event', 'pthread', 'stupa']
    )
    task2 = bld(
        features = 'cxx cprogram testt',
        source   = 'handler_test.cc handler.cc thread.cc',
        target   = 'handler_test',
        includes = '. /usr/local/include/stupa',
        lib      = ['gtest', 'pthread', 'stupa'],)

def dist_hook():
  import Scripting
#  Scripting.g_gz = 'gz'
  Scripting.dist_exts += ['.svn']
